<?php

namespace api\modules\v1\controllers;

use api\controllers\RestController;
use api\modules\v1\services\CourseContent;

/**
 * Default controller for the `v1` module
 */
class ContentController extends RestController
{
    public $modelClass = 'api\modules\v1\services\CourseContent';

    /**
     * 重写create操作，进行用户注册或添加
     * @name: actions
     * @return array
     * @author: rickeryu <lhyfe1987@163.com>
     * @time: 17/11/21 下午4:57
     */
    public function actions() {
        $actions = parent::actions(); // TODO: Change the autogenerated stub
        unset($actions['create'], $actions['update'], $actions['delete'], $actions['index']);
        return $actions;
    }

    /**
     * 返回分类列表
     * @name: actionIndex
     * @return array
     * @author: rickeryu <lhyfe1987@163.com>
     * @time: 2017/11/27 下午2:34
     */
    public function actionIndex($course_id) {
        $content = CourseContent::lists(['status' => CourseContent::STATUS_ACTIVE, 'course_id' => $course_id],true,false,'id ASC');
        return array_values($content);
    }

}
